import json

class Envelope:
    _code = 0
    _msg = ''
    _obj = None
    def __init__(self,o = None ,m = 'success', c = 0):
        self._code = c;
        self._msg = m;
        self._obj = o;

    def set_object(self,obj):
        self._obj = obj;

    def __str__(self):
        res = {}
        res['code'] = self._code;
        res['message'] = self._msg;
        if self._obj != None:
            res['object'] = self._obj;
        return json.dumps(res)